import os,time
from PIL import Image
from django.http import HttpResponse

def uploadimg(myfile):
    # 去处多余的点
    filename = str(time.time()).replace('.','')+'.'+myfile.name.split('.').pop()
    print(str(filename))
    fp = open('./static/pics/'+filename,'wb+')
    for chunk in myfile.chunks():
        fp.write(chunk)
    fp.close()
    #控制是否做缩略图
    # if hassmall == True:
    #     im = Image.open('./static/pics/'+filename)
    #     im.thumbnail((100,100))
    #     im.save('./static/pics/s_'+filename)
    return '/static/pics/'+filename